package com.ehome.user.Utils;

import android.content.Context;
import android.os.CountDownTimer;
import android.widget.TextView;

import com.ehome.user.R;

/**
 * Created by Administrator on 2018/3/10 0010.
 */

public class TimeCount extends CountDownTimer {
    private final Context baseContent;
    TextView button;
    public TimeCount(Context content , long millisInFuture, long countDownInterval, TextView bt) {
        super(millisInFuture, countDownInterval);// 参数依次为总时长,和计时的时间间隔
        baseContent = content;
        this.button=bt;
    }

    @Override
    public void onFinish() {// 计时完毕时触发
        button.setText("获取验证码");
        button.setClickable(true);
//        button.setBackgroundResource(R.drawable.btlogin);

    }

    @Override
    public void onTick(long millisUntilFinished) {// 计时过程显示
        button.setClickable(false);
//        button.setBackgroundResource(R.drawable.bthui);
        button.setTextColor(baseContent.getResources().getColor(R.color.FFF98340));
//        button.setText(millisUntilFinished / 1000 + " 秒后重发");
        button.setText(millisUntilFinished / 1000+"");
        button.append(" 秒后重发");
    }
}
